package com.baizhi.service.impl;

import com.baizhi.dao.BannerDAO;
import com.baizhi.entity.Banner;
import com.baizhi.service.BannerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class BannerServiceImpl implements BannerService {
    Logger logger = LoggerFactory.getLogger(BannerServiceImpl.class);

    @Autowired
    private BannerDAO bannerDAO;
    @Override
    @Transactional(readOnly = true)
    public PageInfo<Banner> selectAll(Integer page,Integer limit) {
        PageHelper.startPage(page,limit);
        PageInfo info = new PageInfo(bannerDAO.selectAll());
        return info;
    }

    @Override
    @Transactional
    public void insert(Banner b) {
        bannerDAO.insert(b);
    }

    @Override
    public void delete(Integer id) {
        bannerDAO.delete(id);
    }

    @Override
    public void update(Banner b) {
        bannerDAO.update(b);
    }

    @Override
    public Banner selectOne(Integer id) {
        logger.debug("111111111111");
        logger.info("222222222222");
        logger.warn("333333333333");
        logger.error("444444444444");
        return bannerDAO.selectOne(id);
    }
}
